package router

import (
	platformController "gitee.com/wangshh_123/cross-pay-go/src/controller/platform"
	"gitee.com/wangshh_123/cross-pay-go/src/middleware"
	"github.com/gin-gonic/gin"
)

// SetupCardholderRouter 设置统一的持卡人路由
func SetupCardholderRouter(api *gin.RouterGroup) {
	// 创建统一的持卡人控制器实例
	cardholderController := platformController.NewCardholderController()

	// 持卡人路由组
	cardholder := api.Group("/cardholder")
	{
		// 基础持卡人操作 - 根据用户平台自动选择
		cardholder.GET("/", middleware.AuthMiddleware(), middleware.PlatformInfoMiddleware(), cardholderController.GetCardholderList)
		cardholder.POST("/", middleware.AuthMiddleware(), middleware.PlatformInfoMiddleware(), cardholderController.CreateCardholder)
		cardholder.POST("/update", middleware.AuthMiddleware(), middleware.PlatformInfoMiddleware(), cardholderController.UpdateCardholder)

		// 指定平台持卡人操作 - 管理员功能
		cardholder.GET("/platform/:platform", middleware.AuthMiddleware(), cardholderController.GetCardholderListByPlatform)
		cardholder.POST("/platform/:platform", middleware.AuthMiddleware(), cardholderController.CreateCardholderByPlatform)
		cardholder.PUT("/platform/:platform", middleware.AuthMiddleware(), cardholderController.UpdateCardholderByPlatform)

		// 获取支持持卡人操作的平台列表
		cardholder.GET("/platforms", cardholderController.GetSupportedPlatforms)
	}
}
